import 'package:flutter/material.dart';

class PaddingAnimationDemo extends StatefulWidget {
  @override
  _PaddingAnimationDemoState createState() => _PaddingAnimationDemoState();
}

class _PaddingAnimationDemoState extends State<PaddingAnimationDemo> with SingleTickerProviderStateMixin{
  Animation<double> _animation;
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(duration: Duration(milliseconds: 1000),vsync: this);
    _animation = Tween<double>(begin: 0,end: 200).animate(_controller);
    _controller.addListener((){
      setState(() {

      });
    });
  }

  @override
  void dispose ()
  {
    _controller.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('位移偏移动画'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            Container(
              child: FlutterLogo(size: 100.0,),
              padding: EdgeInsets.only(left: _animation.value),
            ),
            RaisedButton(
              child: Text('动画开始'),
              onPressed: (){
                _controller.forward();
              },
            )
          ],
        ),
      ),
    );
  }
}
